/**
 * Created by Jay on 2016/6/16.
 */
function edit_vesion(){
    var thsi_id=$.bbq.getState("id");
    mccmsa.ajax({
        url:"versionManageController/getVersionInfo",
        method:"get",
        data: {id:thsi_id},
        success: function (data) {
            //console.log(data);
            $("#appName").val(data.result.appName);
            $("#developNo").val(data.result.developNo);
            $("#versionDesc").val(data.result.versionDesc);
            $("#versionNo").val(data.result.versionNo);
            $("#versionPath").val(data.result.versionPath);
            $("#facilityType").val(data.result.facilityType);
            $("#status").val(data.result.status);
            var version=$("#add_version").Validform({
                btnSubmit:".edit_version",
                tiptype:3,
                label:".label",
                showAllError:true,
                datatype:{
                    "zh1-6":/^[\u4E00-\u9FA5\uf900-\ufa2d]{1,6}$/,
                    "num":/^[0-9]*$/
                },
                ajaxPost:true
            });//表单验证
            //通过$.Tipmsg扩展默认提示信息;
            //$.Tipmsg.w["zh1-6"]="请输入1到6个中文字符！";
            version.tipmsg.w["zh1-6"]="请输入1到6个中文字符！";
            version.addRule([{
                ele:".inputxt:eq(0)",
                datatype:"zh2-4"
                },
                {
                    ele:".inputxt:eq(1)",
                    datatype:"*6-20"
                },
                {
                    ele:".inputxt:eq(2)",
                    datatype:"*",
                },
                {
                    ele:".inputxt:eq(3)",
                    datatype:"*6-20"
                },
                {
                    ele:".inputxt:eq(4)",
                    datatype:"*"
                }
                //{
                //    ele:"select",
                //    datatype:"*"
                //}
            ]);

        }
    })

    $(".edit_version").click(function(){
        //console.log(thsi_id);
        var form_data=$("#add_version").serialize();
        //console.log(form_data+"&id:"+thsi_id);
        mccmsa.ajax({
            url: "versionManageController/updateVersionInfo",
            method: "post",
            data:form_data+"&id="+thsi_id,
            success: function (data) {
                //alert(1);
                //console.log(data.status);
                var this_data_status=data.status;
                if(this_data_status!=200){
                    layer.alert("修改失败");
                    return;
                }
                layer.alert("修改成功");
                mccmsa.goTo("version_control","edit_version");
            }
        })
    })
}